00001 // Emacs Mode Line: -*- Mode:c++;-*- 00002 // ------------------------------------------------------------- 00003 /* 00004 * Copyright (c) 2013 Battelle Memorial Institute 00005 * Licensed under modified BSD License. A copy of this license can be found 00006 * in the LICENSE file in the top level directory of this distribution. 00007 */ 00008 // ------------------------------------------------------------- 00009 // ------------------------------------------------------------- 00010 /** 00011 * @file file_optimizer_implementation.hpp 00012 * @author William A. Perkins 00013 * @date 2016-12-08 14:59:09 d3g096 00014 * 00015 * @brief 00016 * 00017 * 00018 */ 00019 // ------------------------------------------------------------- 00020 // ------------------------------------------------------------- 00021 // Created December 7, 2016 by William A. Perkins 00022 // Last Change: 2013-05-03 12:23:12 d3g096 00023 // ------------------------------------------------------------- 00024 00025 #ifndef _file_optimizer_implementation_hpp_ 00026 #define _file_optimizer_implementation_hpp_ 00027 00028 #include <iosfwd> 00029 #include <string> 00030 #include "optimizer.hpp" 00031 00032 namespace gridpack { 00033 namespace optimization { 00034 00035 // ------------------------------------------------------------- 00036 // class FileOptimizerImplementation 00037 // ------------------------------------------------------------- 00038 /// An abstracte base class for optimizers that require a temporary input file 00039 class FileOptimizerImplementation 00040 : public OptimizerImplementation 00041 { 00042 public: 00043 00044 /// Default constructor. 00045 FileOptimizerImplementation(const parallel::Communicator& comm); 00046 00047 /// Destructor 00048 virtual ~FileOptimizerImplementation(void); 00049 00050 protected: 00051 00052 /// Output file name 00053 std::string p_outputName; 00054 00055 /// Try to run the file? 00056 bool p_runMaybe; 00057 00058 /// Specialized way to configure from property tree 00059 void p_configure(utility::Configuration::CursorPtr props); 00060 00061 /// Specialized way to set file name 00062 void p_setFilename(std::string file); 00063 00064 /// Open a stream to a new temporary file 00065 virtual std::string p_temporaryFileName(void); 00066 00067 /// Write an LP file to the specified stream 00068 virtual void p_write(const p_optimizeMethod& m, std::ostream& out) = 0; 00069 00070 /// Do the problem (specialized) 00071 void p_solve(const p_optimizeMethod& m); 00072 00073 }; 00074 00075 } // namespace optimization 00076 } // namespace gridpack 00077 00078 00079 #endif